home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / machserver / 1.098 / lfs / lfsUsageArray.h < prev    next >
C/C++ Source or Header  |  1990-10-27  |  4KB  |  105 lines

  1. /*
  2.  * lfsUsageArray.h --
  3.  *
  4.  *    Declarations defining the disk resident format of the LFS 
  5.  *    segment usage array. The main purpose of the segment usage array 
  6.  *    is to aid LFS in making intelligent choices for segment to clean
  7.  *    and segments to write. The segment usage array also keeps track of
  8.  *    the disk space usage for the file system.
  9.  *
  10.  * Copyright 1989 Regents of the University of California
  11.  * Permission to use, copy, modify, and distribute this
  12.  * software and its documentation for any purpose and without
  13.  * fee is hereby granted, provided that the above copyright
  14.  * notice appear in all copies.  The University of California
  15.  * makes no representations about the suitability of this
  16.  * software for any purpose.  It is provided "as is" without
  17.  * express or implied warranty.
  18.  *
  19.  * $Header: /sprite/src/kernel/lfs/RCS/lfsUsageArray.h,v 1.5 90/10/19 17:23:12 mendel Exp $ SPRITE (Berkeley)
  20.  */
  21.  
  22. #ifndef _LFSUSAGEARRAY
  23. #define _LFSUSAGEARRAY
  24.  
  25. #ifdef KERNEL
  26. #include <lfsStableMem.h>
  27. #else
  28. #include <kernel/lfsStableMem.h>
  29. #endif
  30. /*
  31.  * The segment usage array layout on disk is described by the following 
  32.  * super block resident structure. 
  33.  * It must be LFS_USAGE_ARRAY_PARAM_SIZE (currently 64 bytes) in size. 
  34.  */
  35. #define    LFS_USAGE_ARRAY_PARAM_SIZE    64
  36.  
  37. typedef struct LfsSegUsageParams {
  38.     int segmentSize;         /* The number of bytes in each of segment. 
  39.                 * Must be a multiple of the file system
  40.                 * block size. */
  41.     int numberSegments;      /* The number of segments in the system. */
  42.     int   minNumClean;    /* The min number of clean segment we allow the
  43.                * system to reach before starting clean. */
  44.     int   minFreeBlocks;  /* The min number of free blocks we allow the
  45.                * system to reach. */
  46.     int      wasteBlocks;      /* The number of blocks we are willing to wasted at
  47.                * the end of a segment. */
  48.     int      numSegsToClean;  /* Number of segment to clean at a time. */
  49.     char  padding[LFS_USAGE_ARRAY_PARAM_SIZE - sizeof(LfsStableMemParams)-6*4];
  50.     LfsStableMemParams     stableMem; /* Memory for locating the array. */
  51. } LfsSegUsageParams;
  52.  
  53.  
  54. /*
  55.  * The checkpoint data of segment usage array is described by a structure
  56.  * LfsSegUsageCheckPoint. The disk resident structure of a checkpoint
  57.  * contains a LfsSegUsageCheckPoint followed by a LfsStableMemCheckPoint.
  58.  */
  59. typedef struct LfsSegUsageCheckPoint {
  60.     int    freeBlocks;    /* Number of free blocks available. */ 
  61.     int numClean;    /* Number of clean segments. */
  62.     int numDirty;    /* Number of dirty segments. */
  63.     int dirtyActiveBytes; /* Number of known active bytes below which a 
  64.                * segment is considered dirty. */
  65.     int    currentSegment;    /* Current segment being written. */
  66.     int    currentBlockOffset; /* Current block offset into last segment being
  67.                  * written. -1 means segment filled. */
  68.     int curSegActiveBytes; /* Active bytes of last segment written. */
  69.     int    previousSegment;   /* Previous segment written. */
  70.     int cleanSegList;    /* First segment in the list of clean segemnts. */
  71. } LfsSegUsageCheckPoint;
  72.  
  73. /*
  74.  * For each segment in a LFS, the segment usage are keeped an 
  75.  * entry of type LfsSegUsageEntry. LfsSegUsageEntry are packed into blocks
  76.  * to form an array index by segment number. 
  77.  */
  78. typedef struct LfsSegUsageEntry {
  79.     int  activeBytes;             /* An estimate of the number of active
  80.                      * bytes in this segment. If the segment
  81.                      * is clean (LFS_SEG_USAGE_CLEAN is set
  82.                      * in flags), then activeBytes contains
  83.                      * the index of the next clean segment. */
  84.     int     timeOfLastWrite;        /* File system time of last write 
  85.                      * in seconds. */
  86.     int  flags;                 /* Flags described below. */
  87. } LfsSegUsageEntry;
  88.  
  89. /*
  90.  * Values for the flags field of the LfsSegUsageEntry.
  91.  *
  92.  * LFS_SEG_USAGE_CLEAN    - The segment has been cleaned and contains no 
  93.  *              live data. 
  94.  * LFS_SEG_USAGE_DIRTY  - The segment is neither full or dirty.
  95.  * LFS_SEG_USAGE_CHAIN    - The segment is a member of checkpoint chain that
  96.  *              hasn't been terminated. 
  97.  */
  98. #define    LFS_SEG_USAGE_CLEAN 0x0001
  99. #define    LFS_SEG_USAGE_DIRTY 0x0002
  100. #define    LFS_SEG_USAGE_CHAIN 0x0004
  101.  
  102.  
  103. #endif /* _LFSUSAGEARRAY */
  104.  
  105.